package com.ruibang.glass.quality.controller.manage;

import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.quality.domain.req.DefectDetailReq;
import com.ruibang.glass.quality.domain.resp.DefectDetailResp;
import com.ruibang.glass.quality.service.DefectDetailService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-01-12  13:48
 * @Description: TODO
 * @Version: 1.0
 */

@RestController
@RequestMapping("/api/quality/manage/defectDetail")
@Api(value = "控制器", tags = {"缺陷详情控制器"})
public class DefectDetailController {

    @Autowired
    private DefectDetailService defectDetailService;

    @PostMapping("/getDefectDetail")
    @ApiOperation(value = "获取缺陷详情", notes = "获取缺陷详情")
    public ResultBody<Map<String, List<DefectDetailResp>>> getDefectDetail(@RequestBody @Valid DefectDetailReq defectDetailReq) {
        return defectDetailService.getDefectDetail(defectDetailReq);
    }

    @PostMapping("/export")
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    @ApiOperation(value = "数据导出", notes = "数据导出")
    public void export(@RequestBody @Valid DefectDetailReq defectDetailReq, HttpServletResponse response) {
        defectDetailService.export(defectDetailReq, response);
    }

}


